The DAX (Data Analysis Expressions) FILTER function is used to return a table that contains only the rows that meet specific criteria. It evaluates a table expression in a context modified by filters, and it is commonly used to filter data based on conditions.
Syntax
FILTER(<table>, <filter_expression>)
table: The table or table expression to filter.
filter_expression: The condition or expression that specifies which rows to include in the filtered table.
Example with Tables
Consider the following table:
Sales Table
Steps to Create the Measure in Power BI Desktop
Open Power BI Desktop.
Load your data into the data model.
Go to the Data view by clicking on the table icon on the left pane.
Select the Sales table.
Click on "New Measure" in the Modeling tab.
Enter the DAX formula into the formula bar:
TotalSales_101 = CALCULATE( SUM(Sales[SalesAmount]), FILTER(Sales, Sales[Product_Id] = 101) )
Press Enter to create measure.
Comments
Post a Comment